package com.fr.elastic;

import org.elasticsearch.index.query.IdsQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;

public class QueryTest {

    // public static void main(String[] args) {
    // BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
    // System.out.println(boolQuery.hasClauses());
    // System.out.println(boolQuery.toString());
    // boolQuery.must(QueryBuilders.termQuery("f1", 1))
    // .must(QueryBuilders.termQuery("f2", 2))
    // .should(QueryBuilders.matchPhraseQuery("f3", "kaka is back"))
    // .should(QueryBuilders.existsQuery("f4"))
    // .mustNot(QueryBuilders.nestedQuery("user", QueryBuilders.termQuery("user.firstName", "kaka")))
    // .should(QueryBuilders.missingQuery("f5"));
    //
    // System.out.println(boolQuery.hasClauses());
    // System.out.println(boolQuery.toString());
    // System.out.println(QueryBuilders.matchAllQuery().toString());
    // TermsBuilder terms = AggregationBuilders.terms("1");
    // terms.field("method");
    // DateHistogramBuilder dateHistogram =
    // AggregationBuilders.dateHistogram("2").field("time").interval(DateHistogramInterval.DAY);
    // dateHistogram.subAggregation(AggregationBuilders.avg("3").field("cost"));
    // terms.subAggregation(dateHistogram);
    // System.out.println("123:"+terms);
    // System.out.println(QueryBuilders.nestedQuery("multDeparture",
    // QueryBuilders.rangeQuery("multDeparture.sellPrice").gt(0)));
    // QueryBuilder q = QueryBuilders.termsQuery("A", A.a, A.b);
    // QueryBuilder query = QueryBuilders.geoDistanceRangeQuery("location")
    // .point(Double.parseDouble("12"), Double.parseDouble("23"))
    // .gt(0)
    // .lte(5*1000)
    // .geoDistance(GeoDistance.PLANE);
    // BoolQueryBuilder query2 = QueryBuilders.boolQuery();
    // for(int i = 0; i < 10000; i ++){
    // query2.should(QueryBuilders.wildcardQuery("aaa", "*"+i+"*"));
    // }
    // TermsBuilder builder = AggregationBuilders.terms("continentDestId").field("continentDestId").size(10);
    // builder.subAggregation(AggregationBuilders.terms("playMethodId").field("playMethodId").size(10));
    // System.out.println(query);
    // }

    public static void main(String[] args) {
        IdsQueryBuilder query = QueryBuilders.idsQuery();
        query.addIds("1", "2", "3", "4");
        System.out.println(query);
    }

    enum A {
        a(1), b(2), c(3);

        int i;

        A(int i) {
            this.i = i;
        }
    }

}
